
import java.util.logging.Level;
import java.util.logging.Logger;

import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.system.AppSettings;

 
public class Engine extends SimpleApplication{
  
  private static Engine engine;
  public static Player player;
  
  public static void main(String args[]) {
    engine = getEngine();
    engine.start();
  }
  
  private Engine()
  {
	  
  }
  
  public static Engine getEngine()
  {
	  if(engine == null)
		  engine = new Engine();
	  return engine;
  }
  
  private BulletAppState bulletAppState;
  private World world;
  private GUI gui;
  public static String GAME_HOME = System.getProperty("user.home") + "/TestGame";
  
 
  //a note for later--
  //render all blocks of a particular type at once - texture switching is expensive
  //also render blocks using octree - group contiguous blocks into one object
  public void simpleInitApp() {
	//Logger.getLogger("").setLevel(Level.SEVERE);
	  
	bulletAppState = new BulletAppState();
	stateManager.attach(bulletAppState);
	//bulletAppState.getPhysicsSpace().enableDebug(assetManager);
	
	player = new Player();
    world = new World();
    gui = new GUI();
    
    world.createNewWorld();
    Renderer.renderChunkMatrix();
    
    //jme3tools.optimize.GeometryBatchFactory.optimize(rootNode);
  }
  
  public void destroy()
  {
	 // world.saveActiveChunks();
  }
  
  public void simpleUpdate(float tpf) {
	player.update();
  }
  
  public AppSettings getSettings()
  {
	  return settings;
  }
  
  public World getWorld()
  {
	  return world;
  }
}